﻿Imports System.Collections.Generic
Imports System.Data
Imports CondorTravel.BC
Imports CondorTravel.BE
Imports CondorTravelUTIL.DL

Public Class ConsultarSolicitudPaquete
    Inherits PaginaBase

    Dim itemgridview As GridViewRow
    Dim casilla As System.Web.UI.WebControls.CheckBox

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load

    End Sub

    Protected Sub btnConsultar_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnConsultar1.Click
        ListarSolicitudesPaq()
    End Sub


    Private Sub ListarSolicitudesPaq()

        Dim objSolicitudPaqBE As New SolicitudPaqueteBE
        Dim objSolicitudPaqBC As New SolicitudPaqueteBC
        Dim bExito As Boolean = False
        Dim sMensaje As String = String.Empty
        Dim objUtil As New Funciones

        objSolicitudPaqBE.CodSolicitud = Val(objUtil.ReemplazarTexto(txtCodSolicitud.Text.Trim))
        objSolicitudPaqBE.NombrePaquete = txtNombrePaq.Text.Trim

        dgPaquete.DataSource = objSolicitudPaqBC.ListaSolicitudPaquete_Busqueda(objSolicitudPaqBE, bExito, sMensaje)
        dgPaquete.DataBind()

    End Sub

    Protected Sub btnSeleccionar_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSeleccionar1.Click

        Dim dt As New DataTable
        Dim sCodigo As String = String.Empty
        Dim sNombre As String = String.Empty
        Dim sFechaIni As String = String.Empty
        Dim sFechaFin As String = String.Empty

        Dim iContador As Integer
        For Each Me.itemgridview In dgPaquete.Rows
            casilla = itemgridview.FindControl("chkSeleccionar")
            If casilla.Checked = True Then
                iContador = iContador + 1
            End If
        Next

        If iContador > 1 Then
            Alerta("Solo se permite seleccionar un registro.", False, String.Empty)
            Exit Sub
        End If

        For Each Me.itemgridview In dgPaquete.Rows
            casilla = itemgridview.FindControl("chkSeleccionar")

            If casilla.Checked = True Then
                scodigo = CType(itemgridview.FindControl("lblcodigo"), Label).Text
                sNombre = CType(itemgridview.FindControl("lblNombre"), Label).Text
                sFechaIni = CType(itemgridview.FindControl("lblFechaIni"), Label).Text
                sFechaFin = CType(itemgridview.FindControl("lblFechaFin"), Label).Text
            End If
        Next

        'Response.Write("<script language=Javascript>window.opener.location.reload();</script>")
        Response.Write("<script language=Javascript>window.close();</script>")
        Session("BSSCodigoSolicitudPaq") = sCodigo
        Session("BSSNombreSolicitudPaq") = sNombre
        Session("BSSFIniSolicitudPaq") = sFechaIni
        Session("BSSFFinSolicitudPaq") = sFechaFin

    End Sub

    Protected Sub btnSalir_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSalir.Click
        Response.Write("<script language=Javascript>window.close();</script>")
    End Sub
End Class